import java.util.HashMap;

/*
 * The register File has two operations either read or write
 * and its inputs are dependent on the intruction memory output 
 */

public class RegisterFile extends Constants {

	public static HashMap<Registers, Integer> registerValues = new HashMap<Registers, Integer>();

	public static int ReadData1 = -1;
	public static int ReadData2 = -1;

	public static void readOperation(Registers ReadRegister1,
			Registers ReadRegister2) {
		ReadData1 = (registerValues.get(ReadRegister1) == null) ? 0
				: registerValues.get(ReadRegister1);
		ReadData2 = (registerValues.get(ReadRegister2) == null) ? 0
				: registerValues.get(ReadRegister2);
	}

	public static void writeOperation(int WriteData, Registers rdRegister,
			Registers rtRegister, Registers raRegister, boolean RegDst,
			boolean RegWrite, boolean jal) {

		if (RegWrite) {
			if (jal) {
				registerValues.put(raRegister, PC.currentAddress + 4);
			} else if (RegDst) {
				registerValues.put(rdRegister, WriteData);
			} else {
				registerValues.put(rtRegister, WriteData);
			}
		}

	}

}
